/*
 * @Author: your name
 * @Date: 2022-01-04 15:35:30
 * @LastEditTime: 2022-01-04 15:37:35
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue_test\src\store\count.js
 */
//求和功能相关的配置
export default {
  namespaced: true,
  actions: {
    jiaOdd(context, value) {
      console.log("actions中的jiaOdd被调用了！", context);
      //console.log("处理了一些事情--jiaOdd");
      //context.dispatch("demo1", value);
      if (context.state.sum % 2) {
        context.commit("JIAODD", value);
      }
    },
    jiaWait(context, value) {
      console.log("actions中的jiaWait被调用了！");
      setTimeout(() => {
        context.commit("JIAWAIT", value);
      }, 300);
    },
  },
  mutations: {
    JIA(state, value) {
      console.log("mutations中的JIA被调用了！");
      state.sum += value;
    },
    JIAN(state, value) {
      console.log("mutations中的JIAN被调用了！");
      state.sum -= value;
    },
    JIAODD(state, value) {
      console.log("mutations中的JIAODD被调用了！");
      state.sum += value;
    },
    JIAWAIT(state, value) {
      console.log("mutations中的JIAWAIT被调用了！");
      state.sum += value;
    },
    Add_PERSON(state, value) {
      console.log("mutations中的Add_PERSON被调用了！");
      state.personList.unshift(value);
    },
  },
  state: {
    sum: 0,
    school: "尚硅谷",
    subject: "前端",
  },
  getters: {
    bigSum(state) {
      return state.sum * 10;
    },
  },
};